﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRS.Core.DataAccess;
using CRS.Core.Entities;
using CRS.Web.UserControls;

namespace CRS.Web.Reports
{
    public partial class SellRoomDailyReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetData();
                
            }
        }

        private void SetData()
        {
            var acc = new CoreDataAccess();
            try
            {
                var list = acc.Session.CreateQuery("From RoomInfo o Order by o.Name").List();
                lbRoom.Items.Clear();
                foreach (RoomInfo obj in list)
                {
                    lbRoom.Items.Add(obj.Name);
                }
                if (lbRoom.Items.Count > 0)
                {
                    lbRoom.SelectedIndex = 0;
                    lblRoomName.Text = lbRoom.Items[0].Text;
                }
                
            }
            finally
            {
                acc.CloseSession();
            }
            GridView1.DataSource = BindList();
            GridView1.DataBind();
        }

        public DataTable BindList()
        {
            var result = new DataTable();
            result.Columns.Add("类别", typeof(string)); //产品名称
            result.Columns.Add("金额", typeof(string)); //单位


            //给该列填值
            DataRow dr = result.NewRow();
            dr["类别"] = "零食";
            dr["金额"] = "10";
            result.Rows.Add(dr);


            DataRow dr1 = result.NewRow();
            dr1["类别"] = "烟洒";
            dr1["金额"] = "100";
            result.Rows.Add(dr1);

            DataRow dr2 = result.NewRow();
            dr2["类别"] = "饮料";
            dr2["金额"] = "100";
            result.Rows.Add(dr2);

            DataRow dr3 = result.NewRow();
            dr3["类别"] = "包厢费";
            dr3["金额"] = "30每小时*5小时=150";
            result.Rows.Add(dr3);

            DataRow dr4 = result.NewRow();
            dr4["类别"] = "其它";
            dr4["金额"] = "80";
            result.Rows.Add(dr4);

            return result;
        }

        protected void lbRoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblRoomName.Text = lbRoom.SelectedValue;
        }
    }
}
